import 'package:flutter/widgets.dart';
import 'package:image_pickers/image_pickers.dart';
import 'package:top_foundation/utils/theme/theme.dart';

class MediaPicker {
  static Future<List<Media>> pickImages(
      {int maxCount = 9, GalleryMode galleryMode = GalleryMode.image}) async {
    final medias = await ImagePickers.pickerPaths(
      galleryMode: galleryMode,
      selectCount: maxCount,
      showGif: true,
      showCamera: true,
      compressSize: 500,
      uiConfig: UIConfig(uiThemeColor: ITheme.themeColor),
      cropConfig: CropConfig(enableCrop: false, width: 2, height: 1),
      language: Language.chinese,
    );
    return medias;
  }

  static void previewImages({
    int initIndex = 0,
    required List<String?> imagePaths,
  }) async {
    ImagePickers.previewImages(imagePaths, initIndex);
  }

  static void previewVideo({
    int initIndex = 0,
    required String path,
  }) async {
    ImagePickers.previewVideo(path);
  }

  static void previewMedias({
    int initIndex = 0,
    required List<Media> imageMedias,
  }) async {
    ImagePickers.previewImagesByMedia(imageMedias, initIndex);
  }
}
